﻿using System;
using UnityEngine;

// Token: 0x0200020D RID: 525
public class PathNode
{
	// Token: 0x06000B0C RID: 2828 RVA: 0x0005D718 File Offset: 0x0005B918
	public PathNode(int x, int z)
	{
		if (PathNode.connections == null)
		{
			PathNode.connections = new PathNode[8];
		}
		this.x = x;
		this.z = z;
	}

	// Token: 0x06000B0D RID: 2829 RVA: 0x0005D744 File Offset: 0x0005B944
	public void ResetValues(int x, int z)
	{
		this.x = x;
		this.z = z;
		this.north = null;
		this.south = null;
		this.est = null;
		this.west = null;
		this.visited = false;
		this.walkable = false;
		this.openRecord = null;
	}

	// Token: 0x06000B0E RID: 2830 RVA: 0x0005D790 File Offset: 0x0005B990
	public bool CanWalkAllDirections()
	{
		return this.north != null && this.south != null && this.est != null && this.west != null;
	}

	// Token: 0x06000B0F RID: 2831 RVA: 0x0005D7C4 File Offset: 0x0005B9C4
	public PathNode[] GetConnections()
	{
		int num = 0;
		bool flag = false;
		bool flag2 = false;
		bool flag3 = false;
		bool flag4 = false;
		if (this.north != null && this.north.walkable)
		{
			this.north.cost = PathNode.normalCost;
			PathNode.connections[num] = this.north;
			num++;
			flag = true;
		}
		if (this.est != null && this.est.walkable)
		{
			this.est.cost = PathNode.normalCost;
			PathNode.connections[num] = this.est;
			num++;
			flag4 = true;
			if (flag && this.north.est != null && this.est.north != null && this.north.est.walkable)
			{
				this.north.est.cost = PathNode.diagonalCost;
				PathNode.connections[num] = this.north.est;
				num++;
			}
		}
		if (this.south != null && this.south.walkable)
		{
			this.south.cost = PathNode.normalCost;
			PathNode.connections[num] = this.south;
			num++;
			flag2 = true;
			if (flag4 && this.south.est != null && this.est.south != null && this.south.est.walkable)
			{
				this.south.est.cost = PathNode.diagonalCost;
				PathNode.connections[num] = this.south.est;
				num++;
			}
		}
		if (this.west != null && this.west.walkable)
		{
			this.west.cost = PathNode.normalCost;
			PathNode.connections[num] = this.west;
			num++;
			flag3 = true;
			if (flag2 && this.south.west != null && this.west.south != null && this.south.west.walkable)
			{
				this.south.west.cost = PathNode.diagonalCost;
				PathNode.connections[num] = this.south.west;
				num++;
			}
		}
		if (flag && flag3 && this.north.west != null && this.west.north != null && this.north.west.walkable)
		{
			this.north.west.cost = PathNode.diagonalCost;
			PathNode.connections[num] = this.north.west;
			num++;
		}
		PathNode.connectionsLength = num;
		return PathNode.connections;
	}

	// Token: 0x04001023 RID: 4131
	private static int normalCost = 100;

	// Token: 0x04001024 RID: 4132
	private static int diagonalCost = 141;

	// Token: 0x04001025 RID: 4133
	public static PathNode[] connections;

	// Token: 0x04001026 RID: 4134
	public static int connectionsLength;

	// Token: 0x04001027 RID: 4135
	public int instanceID;

	// Token: 0x04001028 RID: 4136
	public int x;

	// Token: 0x04001029 RID: 4137
	public int z;

	// Token: 0x0400102A RID: 4138
	public float y;

	// Token: 0x0400102B RID: 4139
	public PathNode north;

	// Token: 0x0400102C RID: 4140
	public PathNode south;

	// Token: 0x0400102D RID: 4141
	public PathNode est;

	// Token: 0x0400102E RID: 4142
	public PathNode west;

	// Token: 0x0400102F RID: 4143
	public bool visited;

	// Token: 0x04001030 RID: 4144
	public bool walkable;

	// Token: 0x04001031 RID: 4145
	public Vector3 realPosition;

	// Token: 0x04001032 RID: 4146
	public int cost;

	// Token: 0x04001033 RID: 4147
	public NodeRecord openRecord;
}
